//
//  PassengerMangerView.swift
//  AirlineReservation
//
//  Created by Kevin on 2020/1/23.
//  Copyright © 2020 Kevin. All rights reserved.
//

import UIKit

class PassengerMangerView: UIView {

    // 乘机人文本
    private lazy var passengerText = UILabel(title: "乘机人",color: UIColor.black)
    // 添加乘机人
    private lazy var addPassengerBtn = UIButton()
    
    // 回调
    public var complete: (() -> Void)?
    
    override func layoutSubviews() {
        // 乘机人文本
        passengerText.frame = CGRect(x: MARGIN, y: 0, width: MARGIN100, height: frame.height)
        passengerText.font = UIFont.boldSystemFont(ofSize: 17)
        addSubview(passengerText)
        // 添加乘机人
        addPassengerBtn.layer.borderWidth = 1
        addPassengerBtn.layer.cornerRadius = 4
        addPassengerBtn.setTitle("+ 乘机人", for: .normal)
        addPassengerBtn.setTitleColor(COLOR_NICE, for: .normal)
        addPassengerBtn.layer.borderColor = UIColor.gray.cgColor
        addPassengerBtn.titleLabel?.font = UIFont.systemFont(ofSize: 12)
        addPassengerBtn.frame = CGRect(x: frame.width - MARGIN90, y: MARGIN15, width: MARGIN70, height: MARGIN30)
        addSubview(addPassengerBtn)
        // 添加乘机人 点击事件
        addPassengerBtn.addTarget(self, action: #selector(clickItem), for: .touchUpInside)
    }

    @objc func clickItem() -> Void {
        if let callback = complete {
            callback()
        }
    }
}
